package com.kylin.eduservice.controller;


import com.kylin.R;
import com.kylin.eduservice.entity.subject.OneSubject;
import com.kylin.eduservice.service.EduSubjectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author kylin
 * @since 2020-07-15
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;

    //添加课程分类
    //获取上传过来文件，把文件内容读取处理
    @PostMapping("/addSubject")
    @ApiOperation("添加课程分类")
    public R addSubject(MultipartFile file){

        //上传过来excel文件
        eduSubjectService.saveSubject(file,eduSubjectService);

        return R.ok();
    }

    //课程分类列表显示（树型）
    @GetMapping("/getAllSubject")
    @ApiOperation("查询课程分类")
    public R getAllSubject(){

        List<OneSubject>  list = eduSubjectService.getAllOneTwoSubject();

        return R.ok().data("list",list);
    }


}

